import Vue from 'vue'
import Vuex from 'vuex'

//先引入  再挂载
Vue.use(Vuex)
//store (一个容器对象，存储Vuex中的state,mutations,actions,getters等)
const state = {
    username:''    
}
const mutations = {
    //mutations是一个方法 可以当作属性使用
    // changename(state,newname){
    //  state.username=newname
    // }
}
const actions = {}
const getters = {
    username: state => localStorage.getItem('username')
  }
export default new Vuex.Store({
  state,
  getters,
  actions,
  mutations
})